package com.itheima.ThreadAPI;

public class MyThread extends Thread{
    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {
            System.out.println(Thread.currentThread().getName()+i);
        }
    }
}

class Test {
    public static void main(String[] args) {
        Thread t1 = new MyThread();
        Thread t2 = new MyThread();
        t1.setName("1号线程");
        t2.setName("2号线程");
        t1.start();
        t2.start();
        // 怎么拿主线程？  currentThread, 哪个线程执行它，它就代表谁
        // 主线程名称就是main
        Thread mainThread = Thread.currentThread();
        System.out.println(mainThread.getName());
        for (int i = 0; i < 3; i++) {
            System.out.println("main主线程"+i);
        }
    }
}